/**
 * @param {string} haystack
 * @param {string} needle
 * @return {number}
 */
var strStr = function (haystack, needle) {
  // 空
  if (!needle) return 0
  // 定义两指针
  let start = 0
  let end = start + 1
  // 遍历并截取
  while (start < haystack.length) {
    let str = haystack.slice(start, end)
    // 比较字符串
    if (str == needle) {
      return start
    }
    // 继续向后移
    if (end < haystack.length) {
      end++
    } else {
      start++
      end = start + 1
    }
  }
  return -1
};